package devTest.Game 
{
	import flash.display.DisplayObject;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author miquel
	 */
	public class CPrincipal extends Sprite 
	{
		[Embed(source="../../../lib/images/button_Empezar.png")]
		private var m_pStart:			Class;

		[Embed(source="../../../lib/images/button_Empezar_on.png")]
		private var m_pOnStart:			Class;
		
		[Embed(source="../../../lib/images/button_Empezar_onclick.png")]
		private var m_pOnClickStart:	Class;
		
		[Embed(source = "../../../lib/fonts/lucon.ttf",
			fontName = "Lucon", 
			mimeType = "application/x-font-truetype", 
			fontWeight="normal", 
			fontStyle="normal", 
	//			unicodeRange="englishRange", 
			advancedAntiAliasing="true", 
			embedAsCFF = "false")]
		private var myEmbeddedFont:		Class;

		
		//screen objects 	
		private var tKeys:				TextField 			= null;
		private var m_pButton:			SimpleButton 		= null;
		
		//stage
		private var myStage:			Stage				= null;
		
		//control
		private var m_bStateActivate:	Boolean				= false;
		
		
		
		/**
		 * constructor
		 */
		public function CPrincipal(s:Stage) 
		{
			super();
			myStage = s;
		}
		

		/**
		 * Init: Show message and button to start the game
		 */
		public function Init():void
		{
			var l_bmpButton:		DisplayObject = new m_pStart();
			var l_bmpButtonOver:	DisplayObject = new m_pOnStart();
			var l_bmpButtonClick:	DisplayObject = new m_pOnClickStart();
			
			m_pButton = new SimpleButton(l_bmpButton,l_bmpButtonOver,l_bmpButtonClick,l_bmpButtonClick);
			m_pButton.x = 300;
			m_pButton.y = 500;
			m_pButton.addEventListener(MouseEvent.CLICK, ReturnState);
			m_pButton.hitTestState = l_bmpButtonClick;
			addChild(m_pButton);

			var l_pTextFormat:TextFormat = new TextFormat("Lucon", 40);
			
			tKeys = new TextField();
			tKeys.embedFonts = true;
			tKeys.x = 100;
			tKeys.y = 400;
			tKeys.width = 1000;
			tKeys.height = 50;
			tKeys.defaultTextFormat = l_pTextFormat;
			tKeys.textColor = 0xFFFFFF;
			tKeys.text = "Pulse Empezar Para Jugar";
			tKeys.selectable = false;
			tKeys.mouseEnabled = false;
			tKeys.background = false;
			addChild(tKeys);
		}
		
		private function ReturnState(e:MouseEvent):void 
		{
			m_bStateActivate = true;
		}
			
		public function Done():Boolean
		{
			return m_bStateActivate;	
			trace(m_bStateActivate );
		}
	}

}